package com.ds.cli.command;

import cn.hutool.core.bean.BeanUtil;
import com.ds.generator.MainGenerator;
import com.ds.model.MainTemplateConfig;
import lombok.Data;
import picocli.CommandLine;


import java.util.concurrent.Callable;

@CommandLine.Command(name = "generate", mixinStandardHelpOptions = true)
@Data
public class GenerateCommand implements Callable<Integer> {
    @CommandLine.Option(names = {"-a", "--author"}, description = "作者", arity = "0..1" , interactive = true,echo = true)
    private String author = "ds";

    /**
     * 输出路径
     */
    @CommandLine.Option(names = {"-o", "--outputText"}, description = "输出文本", arity = "0..1" , interactive = true,echo = true)
    private String outputText = "结果";

    /**
     * 是否循环生成
     */
    @CommandLine.Option(names = {"-l", "--loop"}, description = "是否循环" , arity = "0..1" , interactive = true,echo = true)
    private boolean loop;

    @Override
    public Integer call() throws Exception {
        MainTemplateConfig mainTemplateConfig = new MainTemplateConfig();
        BeanUtil.copyProperties(this, mainTemplateConfig);
        MainGenerator.doGenerate(mainTemplateConfig);
        return 0;
    }
}
